package com.fhj.movie.adapter;

import java.util.LinkedList;
import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.fhj.movie.activity.HyyLoginActivity;
import com.fhj.movie.entity.FilmEntity;
import com.fhj.movie_fhj_01.R;
import com.fhj.utils.ImageDownload;

public class FilmFurListAdapter extends BaseAdapter {

	private LinkedList<FilmEntity> lists;

	private Context context;
	private ImageDownload mImageDownload;

	public FilmFurListAdapter(Context context, LinkedList<FilmEntity> lists) {

		this.context = context;
		this.lists = lists;
		
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lists.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.film_fur_lv_item, parent, false);
			holder.filmImg = (ImageView) convertView
					.findViewById(R.id.film_lv_item_image);
			holder.filmIntro = (TextView) convertView
					.findViewById(R.id.film_lv_item_intro);
			holder.filmName = (TextView) convertView
					.findViewById(R.id.film_lv_item_title);
			holder.filmLikeNum = (TextView) convertView
					.findViewById(R.id.film_lv_item_notifyCount);
			holder.filmScreening = (TextView) convertView
					.findViewById(R.id.film_lv_item_screening);
			holder.filmBuyTicket = (TextView)convertView.findViewById(R.id.film_lv_item_buyticket);
			

			convertView.setTag(holder);

		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		mImageDownload = ImageDownload.getInstance(context);
		FilmEntity entity = lists.get(position);
		mImageDownload.downLoadImage(holder.filmImg, entity.getLogo());
		holder.filmName.setText(entity.getName());
		holder.filmIntro.setText(entity.getHighLight());
		holder.filmLikeNum.setText(entity.getNotifyCount() + "人想看");
		holder.filmScreening.setText(entity.getScreenings());
		holder.filmBuyTicket.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent=new Intent(context,HyyLoginActivity.class);
				context.startActivity(intent);
			}
		});

		return convertView;
	}

	static class ViewHolder {
		ImageView filmImg;
		TextView filmName;
		TextView filmIntro;
		TextView filmLikeNum;
		TextView filmScreening;
		TextView filmBuyTicket;
	}

}
